package com.yihaodian.search;

import org.junit.Assert;
import org.junit.Test;

import com.yihaodian.index.AbstractTest;

public abstract class SearchTestFramework extends AbstractTest {
	public static boolean enable_assert = true;
	public static boolean wait_flush = false;

	@Test
	public void testSearch() throws Exception {
		search(field_id, product_id);

		index();

		Thread.sleep(3000);

		int hit = search(field_id, product_id);

		if(enable_assert)
			Assert.assertTrue(hit > 0);

		hit = search(field_category, product_category);
		
		if(enable_assert)
			Assert.assertTrue(hit > 0);
		
		hit = search("search", "手机");
		if(enable_assert)
			Assert.assertTrue(hit > 0);
		
		if(wait_flush)
			Thread.sleep(20000);
	}

	public abstract int search(String field, String value) throws Exception;

	public abstract void index() throws Exception;
}
